package com.ijunfu.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 * @Title  : 
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2023/12/4 15:25
 * @Version: 1.0
 * @Motto  : 世界很大 世界很小
 *
 */
@Slf4j
@RestController
@RequestMapping("/greeting")
public class GreetingController {

    @Resource
    private MessageSource messageSource;

    @GetMapping
    public String greeting() {

        String author = messageSource.getMessage("author", null, LocaleContextHolder.getLocale());

        log.info("{}", author);
        return "Hello, "+ author+"!";
    }
}
